package keter.combofs.model;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * Created by gulx@neusoft.com on 2019/11/11.
 */
public class ComboFile {
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    private String name = null;

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    /**
     * 文件存储相对路径
     */
    private String path = null;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    private Long id = null;

    public Map<String, String> getMeta() {
        return meta;
    }

    public void setMeta(Map<String, String> meta) {
        this.meta = meta;
    }

    private Map<String,String> meta = null;

    /**
     * 读取文件字节流
     * @return
     */
    public byte[] getBytes() {
        return fileBytes;
    }

    public void setFileBytes(byte[] fileBytes) {
        this.fileBytes = fileBytes;
    }

    private byte[] fileBytes;


    public static  ComboFile build(Long id, String fileName, String path) {
        return build(id,fileName,path,null,null);
    }


    public static  ComboFile build(Long id, String fileName, String path, Map<String,String> meta, byte[] fileBytes) {
        ComboFile comboFile = new ComboFile();
        comboFile.setId(id);
        comboFile.setName(fileName);
        comboFile.setPath(path);
        comboFile.setMeta(meta==null? Maps.newHashMap():meta);
        comboFile.setFileBytes(fileBytes);
        return comboFile;
    }

}
